package com.dkm.biz.gl.repository.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.gl.domain.EavSetGroupAttrTree;
import com.dkm.biz.gl.persistence.dao.EavSetGroupAttrTreeQueryDao;
import com.dkm.biz.gl.persistence.entity.EavSetGroupAttrTreePo;
import com.dkm.biz.gl.repository.EavSetGroupAttrTreeRepository;
import com.dkm.biz.repository.AbstractRepository;

/**
 * 对象功能:skg_eav_group_attr_tree Repository接口的实现类
 * 开发公司:SKG.COM
 * 开发人员:Yuki
 * 创建时间:2014-12-17 11:36:45
 */
@Repository
public class EavSetGroupAttrTreeRepositoryImpl extends AbstractRepository<String, EavSetGroupAttrTreePo,EavSetGroupAttrTree> implements EavSetGroupAttrTreeRepository{
	  
	@Resource
	private  EavSetGroupAttrTreeQueryDao eavSetGroupAttrTreeQueryDao;

	public EavSetGroupAttrTree newInstance() {
		EavSetGroupAttrTreePo po = new EavSetGroupAttrTreePo();
		EavSetGroupAttrTree eavSetGroupAttrTree = SpringHelper.getBean(EavSetGroupAttrTree.class);
		eavSetGroupAttrTree.setData(po);
		return eavSetGroupAttrTree;
	}

	public EavSetGroupAttrTree newInstance(EavSetGroupAttrTreePo po) {
		EavSetGroupAttrTree eavSetGroupAttrTree = SpringHelper.getBean(EavSetGroupAttrTree.class);
		eavSetGroupAttrTree.setData(po);
		return eavSetGroupAttrTree;
	} 
	
	@Override
	protected IQueryDao<String, EavSetGroupAttrTreePo> getQueryDao() {
		return eavSetGroupAttrTreeQueryDao;
	}
	
	public List<EavSetGroupAttrTreePo> findBySetId(String setId){
		Map<String,Object> params=new HashMap<String,Object>();
		params.put("setId",setId);
		List<EavSetGroupAttrTreePo> list = eavSetGroupAttrTreeQueryDao.findByKey("findBySetId", params);
		for(EavSetGroupAttrTreePo eavSetGroupAttrTreePo:list){
			if(eavSetGroupAttrTreePo.getIsMainSku().equals("false")){
				eavSetGroupAttrTreePo.setMainSkuFlag(false);
			}else{
				eavSetGroupAttrTreePo.setMainSkuFlag(true);
			}
		}
		System.out.println(list);
		//return convertToTree(list);
		return list;
	}
	
}
